aboutsummaryrefslogtreecommitdiff
path: root/bfd/ihex.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-03-10 10:46:17 +1030
committerAlan Modra <amodra@gmail.com>2020-03-10 11:05:07 +1030
commit6b5e16ffd3e8886fa3fb90d63e3200fcc373848e (patch)
tree37607be13de9a44bbaabf29c15e9668bca45a4d2 /bfd/ihex.c
parent384f368958f2a5bb083660e58e5f8a010e6ad429 (diff)
downloadgdb-6b5e16ffd3e8886fa3fb90d63e3200fcc373848e.zip
gdb-6b5e16ffd3e8886fa3fb90d63e3200fcc373848e.tar.gz
gdb-6b5e16ffd3e8886fa3fb90d63e3200fcc373848e.tar.bz2
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.
Diffstat (limited to 'bfd/ihex.c')
-rw-r--r--bfd/ihex.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/bfd/ihex.c b/bfd/ihex.c
index 68671cc..ca36043 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;