This is the mail archive of the gdb-patches@sourceware.cygnus.com 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]

[Patch] option -noreloc in add-symbol-file (linux module debugging)


Hi,

Following patch adds an option -noreloc to command add-symbol-file.
This will allow working around reloction problems if an object file can be
relocated using ld.

linux kernel module debugging:
Buid a relocated file from module file using ld. Get text, data and bss
addresses by generating a module map. Then load it using add-symbol-file with
-noreloc flag which will load it without performing relocations.

This patch includes changes for x86-elf only.

Can this patch be included in gdb?
Thanks.
-- 
Amit Kale
Veritas Software ( http://www.veritas.com )
diff -Naur gdb-20000314/gdb/solib.c gdb/gdb/solib.c
--- gdb-20000314/gdb/solib.c	Mon Mar  6 23:34:56 2000
+++ gdb/gdb/solib.c	Fri Mar 24 13:13:56 2000
@@ -1112,7 +1112,7 @@
   section_addrs.text_addr = text_addr;
   so->objfile =
     symbol_file_add (so->so_name, so->from_tty,
-		     &section_addrs, 0, OBJF_SHARED);
+		     &section_addrs, 0, OBJF_SHARED, 0);
   return (1);
 }
 
diff -Naur gdb-20000314/gdb/symfile.c gdb/gdb/symfile.c
--- gdb-20000314/gdb/symfile.c	Thu Feb  3 09:44:35 2000
+++ gdb/gdb/symfile.c	Fri Mar 24 13:36:35 2000
@@ -525,11 +525,12 @@
    the symbol reading (and complaints can be more terse about it).  */
 
 void
-syms_from_objfile (objfile, addrs, mainline, verbo)
+syms_from_objfile (objfile, addrs, mainline, verbo, noreloc)
      struct objfile *objfile;
      struct section_addr_info *addrs;
      int mainline;
      int verbo;
+     int noreloc;
 {
   struct section_offsets *section_offsets;
   asection *lower_sect;
@@ -584,7 +585,7 @@
 
      We no longer warn if the lowest section is not a text segment (as
      happens for the PA64 port.  */
-  if (mainline)
+  if (mainline || noreloc)
     {
       /* No offset from objfile addresses.  */
       addrs -> text_addr = 0;
@@ -751,7 +752,14 @@
     }
 #endif /* not IBM6000_TARGET */
 
-  (*objfile->sf->sym_read) (objfile, mainline);
+  if (noreloc)
+    {
+      (*objfile->sf->sym_read) (objfile, 1);
+    }
+  else 
+    {
+      (*objfile->sf->sym_read) (objfile, mainline);
+    }
 
   if (!have_partial_symbols () && !have_full_symbols ())
     {
@@ -829,12 +837,13 @@
    Upon failure, jumps back to command level (never returns). */
 
 struct objfile *
-symbol_file_add (name, from_tty, addrs, mainline, flags)
+symbol_file_add (name, from_tty, addrs, mainline, flags, noreloc)
      char *name;
      int from_tty;
      struct section_addr_info *addrs;
      int mainline;
      int flags;
+     int noreloc;
 {
   struct objfile *objfile;
   struct partial_symtab *psymtab;
@@ -887,7 +896,7 @@
 	      gdb_flush (gdb_stdout);
 	    }
 	}
-      syms_from_objfile (objfile, addrs, mainline, from_tty);
+      syms_from_objfile (objfile, addrs, mainline, from_tty, noreloc);
     }
 
   /* We now have at least a partial symbol table.  Check to see if the
@@ -1021,7 +1030,7 @@
 		return;
 	      else if (text_relocation == (CORE_ADDR) -1)
 		{
-		  symbol_file_add (name, from_tty, NULL, 1, flags);
+		  symbol_file_add (name, from_tty, NULL, 1, flags, 0);
 #ifdef HPUXHPPA
 		  RESET_HP_UX_GLOBALS ();
 #endif
@@ -1031,7 +1040,7 @@
 		  struct section_addr_info section_addrs;
 		  memset (&section_addrs, 0, sizeof (section_addrs));
 		  section_addrs.text_addr = (CORE_ADDR) text_relocation;
-		  symbol_file_add (name, from_tty, &section_addrs, 0, flags);
+		  symbol_file_add (name, from_tty, &section_addrs, 0, flags, 0);
 		}
 
 	      /* Getting new symbols may change our opinion about what is
@@ -1475,6 +1484,7 @@
     char *value;
   } opt[SECT_OFF_MAX];
   struct section_addr_info section_addrs;
+  int noreloc = 0;
 
   dont_repeat ();
 
@@ -1564,6 +1574,10 @@
  	      opt[option_index].name = arg + 2;
  	    }
  	}
+      else if (STREQN (arg, "-noreloc", 8))
+ 	{
+		noreloc = 1;
+	}
       else 
         {
 	  error ("Unknown option `%s'", arg);
@@ -1634,10 +1648,12 @@
     }
   else
     {
-      CORE_ADDR text_addr;
-      target_link (name, &text_addr);  
-      if (text_addr == (CORE_ADDR) -1)
-	error("Don't know how to get text start location for this file");
+      CORE_ADDR text_addr = 0;
+      if (!noreloc) {
+	      target_link (name, &text_addr);  
+	      if (text_addr == (CORE_ADDR) -1)
+		error("Don't know how to get text start location for this file");
+      }
       section_addrs.text_addr = text_addr;
       section_addrs.data_addr = 0;
       section_addrs.bss_addr = 0;
@@ -1647,7 +1663,7 @@
   if (from_tty && (!query ("%s", "")))
     error ("Not confirmed.");
 
-  symbol_file_add (name, from_tty, &section_addrs, 0, flags);
+  symbol_file_add (name, from_tty, &section_addrs, 0, flags, noreloc);
 
   /* Getting new symbols may change our opinion about what is
      frameless.  */
diff -Naur gdb-20000314/gdb/symfile.h gdb/gdb/symfile.h
--- gdb-20000314/gdb/symfile.h	Tue Oct 19 08:16:39 1999
+++ gdb/gdb/symfile.h	Fri Mar 24 13:13:46 2000
@@ -158,7 +158,8 @@
 init_entry_point_info PARAMS ((struct objfile *));
 
 extern void
-syms_from_objfile PARAMS ((struct objfile *, struct section_addr_info *, int, int));
+syms_from_objfile PARAMS ((struct objfile *, struct section_addr_info *, int,
+			   int, int));
 
 extern void
 new_symfile_objfile PARAMS ((struct objfile *, int, int));
diff -Naur gdb-20000314/gdb/symtab.h gdb/gdb/symtab.h
--- gdb-20000314/gdb/symtab.h	Tue Mar  7 10:03:52 2000
+++ gdb/gdb/symtab.h	Fri Mar 24 13:13:37 2000
@@ -1440,7 +1440,7 @@
 clear_solib PARAMS ((void));
 
 extern struct objfile *
-symbol_file_add PARAMS ((char *, int, struct section_addr_info *, int, int));
+symbol_file_add PARAMS ((char *, int, struct section_addr_info *, int, int, int));
 
 /* source.c */
 

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