[binutils-gdb] Fix a potential illegal memory access when creating an srec format file.

Nick Clifton nickc@sourceware.org
Wed Oct 28 11:08:35 GMT 2020


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

commit 2aec1123f9ec86cd190767c9852cb77ed2c017ec
Author: Nick Clifton <nickc@redhat.com>
Date:   Wed Oct 28 11:07:02 2020 +0000

    Fix a potential illegal memory access when creating an srec format file.
    
            PR 26774
            * srec.c (srec_write_symbols): Do not emit symbols in sections
            that have been removed from the output.

Diff:
---
 bfd/ChangeLog | 6 ++++++
 bfd/srec.c    | 5 ++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index d93b27bcede..30bd85d1a9d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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
diff --git a/bfd/srec.c b/bfd/srec.c
index ef7eb439959..6cbe3309e4a 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -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;


More information about the Binutils-cvs mailing list