Blame SOURCES/gdb-6.6-buildid-locate-solib-missing-ids.patch

01917d
Index: gdb-7.5.50.20130310/gdb/solib-svr4.c
01917d
===================================================================
01917d
--- gdb-7.5.50.20130310.orig/gdb/solib-svr4.c	2013-03-10 16:37:49.000000000 +0100
01917d
+++ gdb-7.5.50.20130310/gdb/solib-svr4.c	2013-03-10 16:43:45.498585091 +0100
01917d
@@ -1225,14 +1225,27 @@ svr4_read_so_list (CORE_ADDR lm, struct
01917d
 	}
01917d
 
01917d
       {
01917d
-	struct elf_build_id *build_id;
01917d
+	struct elf_build_id *build_id = NULL;
01917d
 
01917d
 	strncpy (new->so_original_name, buffer, SO_NAME_MAX_PATH_SIZE - 1);
01917d
 	new->so_original_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
01917d
 	/* May get overwritten below.  */
01917d
 	strcpy (new->so_name, new->so_original_name);
01917d
 
01917d
-	build_id = build_id_addr_get (new->lm_info->l_ld);
01917d
+	/* In the case the main executable was found according to its build-id
01917d
+	   (from a core file) prevent loading a different build of a library
01917d
+	   with accidentally the same SO_NAME.
01917d
+
01917d
+	   It suppresses bogus backtraces (and prints "??" there instead) if
01917d
+	   the on-disk files no longer match the running program version.
01917d
+
01917d
+	   If the main executable was not loaded according to its build-id do
01917d
+	   not do any build-id checking of the libraries.  There may be missing
01917d
+	   build-ids dumped in the core file and we would map all the libraries
01917d
+	   to the only existing file loaded that time - the executable.  */
01917d
+	if (symfile_objfile != NULL
01917d
+	    && (symfile_objfile->flags & OBJF_BUILD_ID_CORE_LOADED) != 0)
01917d
+	  build_id = build_id_addr_get (new->lm_info->l_ld);
01917d
 	if (build_id != NULL)
01917d
 	  {
01917d
 	    char *name, *build_id_filename;
01917d
@@ -1247,23 +1260,7 @@ svr4_read_so_list (CORE_ADDR lm, struct
01917d
 		xfree (name);
01917d
 	      }
01917d
 	    else
01917d
-	      {
01917d
-		debug_print_missing (new->so_name, build_id_filename);
01917d
-
01917d
-		/* In the case the main executable was found according to
01917d
-		   its build-id (from a core file) prevent loading
01917d
-		   a different build of a library with accidentally the
01917d
-		   same SO_NAME.
01917d
-
01917d
-		   It suppresses bogus backtraces (and prints "??" there
01917d
-		   instead) if the on-disk files no longer match the
01917d
-		   running program version.  */
01917d
-
01917d
-		if (symfile_objfile != NULL
01917d
-		    && (symfile_objfile->flags
01917d
-			& OBJF_BUILD_ID_CORE_LOADED) != 0)
01917d
-		  new->so_name[0] = 0;
01917d
-	      }
01917d
+	      debug_print_missing (new->so_name, build_id_filename);
01917d
 
01917d
 	    xfree (build_id_filename);
01917d
 	    xfree (build_id);