]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix a potential illegal memory access when creating an srec format file.
authorNick Clifton <nickc@redhat.com>
Wed, 28 Oct 2020 11:07:02 +0000 (11:07 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 28 Oct 2020 11:07:02 +0000 (11:07 +0000)
PR 26774
* srec.c (srec_write_symbols): Do not emit symbols in sections
that have been removed from the output.

bfd/ChangeLog
bfd/srec.c

index d93b27bcedefc40f7120214a441f11d10de60f3d..30bd85d1a9d254504bd459c83e38b019fce82364 100644 (file)
@@ -1,3 +1,9 @@
+2020-10-28  Nick Clifton  <nickc@redhat.com>
+
+       PR 26774
+       * srec.c (srec_write_symbols): Do not emit symbols in sections
+       that have been removed from the output.
+
 2020-10-27  Nick Clifton  <nickc@redhat.com>
 
        * elf64-hppa.c (elf_hppa_final_link_relocate): Check that the
index ef7eb43995902693aaf410373e327da178973b6b..6cbe3309e4a09476bd67f742611841ac54f71e1a 100644 (file)
@@ -1085,8 +1085,11 @@ srec_write_symbols (bfd *abfd)
       for (i = 0; i < count; i++)
        {
          asymbol *s = table[i];
+
          if (! bfd_is_local_label (abfd, s)
-             && (s->flags & BSF_DEBUGGING) == 0)
+             && (s->flags & BSF_DEBUGGING) == 0
+             && s->section != NULL
+             && s->section->output_section != NULL)
            {
              /* Just dump out non debug symbols.  */
              char buf[43], *p;