[binutils-gdb] PR25648, objcopy SIGSEGV in ihex_write_record
Alan Modra
amodra@sourceware.org
Tue Mar 10 00:36:56 GMT 2020
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6b5e16ffd3e8886fa3fb90d63e3200fcc373848e
commit 6b5e16ffd3e8886fa3fb90d63e3200fcc373848e
Author: Alan Modra <amodra@gmail.com>
Date: Tue Mar 10 10:46:17 2020 +1030
PR25648, objcopy SIGSEGV in ihex_write_record
ihex_set_section_contents sorts records stored on the tdata.ihex_data
list by address, but ihex_write_object_contents went too far in
assuming they were not overlapping. This patch fixes the problem by
not assuming anything about addresses in ihex_write_object_contents.
PR 25648
* ihex.c (ihex_write_object_contents): Don't assume ordering of
addresses here. Remove dead code.
Diff:
---
bfd/ChangeLog | 6 ++++++
bfd/ihex.c | 9 ++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 371e505392d..67858c7538b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2020-03-10 Alan Modra <amodra@gmail.com>
+
+ PR 25648
+ * ihex.c (ihex_write_object_contents): Don't assume ordering of
+ addresses here.
+
2020-03-09 Alan Modra <amodra@gmail.com>
* wasm-module.c (wasm_scan): Sanity check file name length
diff --git a/bfd/ihex.c b/bfd/ihex.c
index 68671cc6239..ca36043fe2d 100644
--- a/bfd/ihex.c
+++ b/bfd/ihex.c
@@ -811,16 +811,15 @@ ihex_write_object_contents (bfd *abfd)
if (count > CHUNK)
now = CHUNK;
- if (where > segbase + extbase + 0xffff)
+ if (where < extbase
+ || where - extbase < segbase
+ || where - extbase - segbase > 0xffff)
{
bfd_byte addr[2];
/* We need a new base address. */
- if (where <= 0xfffff)
+ if (extbase == 0 && where <= 0xfffff)
{
- /* The addresses should be sorted. */
- BFD_ASSERT (extbase == 0);
-
segbase = where & 0xf0000;
addr[0] = (bfd_byte)(segbase >> 12) & 0xff;
addr[1] = (bfd_byte)(segbase >> 4) & 0xff;
More information about the Binutils-cvs
mailing list