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

[binutils-gdb] PR22127, as segfaults assembling invalid .reloc


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

commit 2578f2f307f7e80caa0bce32c7fa880d579e736b
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Sep 14 10:19:31 2017 +0930

    PR22127, as segfaults assembling invalid .reloc
    
    "sec" gets set to NULL on errors in the offset expression.  This patch
    disables part of the reloc expression processing that needs "sec"
    valid.  I didn't disable the entire reloc expression handling so that
    errors in the reloc expression are reported even when the offset
    expression has an error.
    
    	PR 22127
    	* write.c (resolve_reloc_expr_symbols): Don't segfault when
    	sec has been set to NULL.

Diff:
---
 gas/ChangeLog | 6 ++++++
 gas/write.c   | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 1bbd8b8..86cf17e 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,9 @@
+2017-09-14  Alan Modra  <amodra@gmail.com>
+
+	PR 22127
+	* write.c (resolve_reloc_expr_symbols): Don't segfault when
+	sec has been set to NULL.
+
 2017-09-09  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* config/tc-i386.c (NOTRACK_PREFIX): Removed.
diff --git a/gas/write.c b/gas/write.c
index 4f6547d..df88905 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -724,7 +724,7 @@ resolve_reloc_expr_symbols (void)
 	      as_bad_where (r->file, r->line, _("invalid reloc expression"));
 	      sec = NULL;
 	    }
-	  else if (sym != NULL)
+	  else if (sym != NULL && sec != NULL)
 	    {
 	      /* Convert relocs against local symbols to refer to the
 	         corresponding section symbol plus offset instead.  Keep


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