This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

[commit/elf] Avoid crashes on old MIPS binaries


There's an obvious gotcha in elf_symtab_read: it may pass a NULL
pointer to gdbarch_elf_make_msymbol_special, which is then likely to
crash.

This happens any time record_minimal_symbol returns NULL.  There are
several cases where this will happen, e.g. __gnu_compiled or
__gcc2_compiled.  (see prim_record_minimal_symbol_and_info).  GCC
doesn't generate these any more, but we happened to load an old binary
into a new GDB.

Tested on arm-none-eabi and x86_64-linux, checked in.

2009-11-13  Maciej W. Rozycki  <macro@codesourcery.com>

	* elfread.c (elf_symtab_read): Only mark a minimal symbol as
	special if it actually exists.  Merge the checks for this
	conditions.

---
 gdb/elfread.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: gdb/elfread.c
===================================================================
--- gdb/elfread.c.orig	2009-11-05 17:10:08.000000000 -0800
+++ gdb/elfread.c	2009-11-13 09:23:43.000000000 -0800
@@ -531,10 +531,10 @@ elf_symtab_read (struct objfile *objfile
 
 	      if (elf_sym)
 		MSYMBOL_SIZE(msym) = elf_sym->internal_elf_sym.st_size;
+	  
+	      msym->filename = filesymname;
+	      gdbarch_elf_make_msymbol_special (gdbarch, sym, msym);
 	    }
-	  if (msym != NULL)
-	    msym->filename = filesymname;
-	  gdbarch_elf_make_msymbol_special (gdbarch, sym, msym);
 
 	  /* For @plt symbols, also record a trampoline to the
 	     destination symbol.  The @plt symbol will be used in

-- 
Daniel Jacobowitz
CodeSourcery


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