This is the mail archive of the gdb@sources.redhat.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]
Other format: [Raw text]

Re: MIPS64 problem with symbols


At Mon, 18 Aug 2003 03:15:41 +0000 (UTC), "Peter Reilley" wrote:
> I have built a GDB cross tool for the MIPS 64 bit processor hosted
> on Intel Linux.   GDB works OK in controlling the target but symbols
> fail to load.   In particular, the start address is truncated to 32 bits.
> My base address is 0xffffffffa0080000.   When I load symbols
> I get an error message;
> 
> (Internal error: pc 0xa0080000 in read in psymtab, but not in symtab.)
> 
> The symbols in the elf file look OK so I think that the problem is
> in GDB.   Is cross GDB known to work on 64 bit targets when hosted
> on a 32 bit Intel host?

what kind of symbols?

I ran across something the other week w/ STABS-in-ELF, which i solved
like the following patches, but i've not tested them well for MIPS,
let alone for other targets.

i'm a bit uncomfortable with them because not all of the the stabs
values are VMAs, but it would have been harder to fix it better (and
i'm not really worried about 2G offsets into peoples' .o files /
executables).  (If you've got an executable or .o file that big, use a
better bloody debugging format.  8-)

they did do well enough for my few initial tests, though, which were
addr2line and objdump --stabs on KSEG0/KSEG1 programs (kernels,
firmware).


Consider these contributed.  If somebody wants to test them well
enough to be included, great, but i've got other fish to fry right
now.  8-)


chris
--
[ bfd/ChangeLog ]

	* syms.c (_bfd_stab_section_find_nearest_line): Handle sign
	extension of VMAs used in stabs.

[ gas/ChangeLog ]

	* rddbg.c (read_section_stabs_debugging_info): Handle sign
	extension of VMAs used in stabs.

Index: bfd/syms.c
===================================================================
RCS file: /projects/bbp/cvsroot/systemsw/tools/src/binutils/bfd/syms.c,v
retrieving revision 1.1.1.9
retrieving revision 1.10
diff -u -p -r1.1.1.9 -r1.10
--- syms.c	2003/07/26 05:39:17	1.1.1.9
+++ syms.c	2003/08/07 22:46:07	1.10
@@ -899,12 +899,17 @@ _bfd_stab_section_find_nearest_line (bfd
   char *directory_name;
   int saw_fun;
   bfd_boolean saw_line, saw_func;
+  int sext_vma;
 
   *pfound = FALSE;
   *pfilename = bfd_get_filename (abfd);
   *pfnname = NULL;
   *pline = 0;
 
+  sext_vma = bfd_get_sign_extend_vma (abfd);
+  if (sext_vma == -1)
+    sext_vma = 0;
+
   /* Stabs entries use a 12 byte format:
        4 byte string table index
        1 byte stab type
@@ -1111,7 +1116,10 @@ _bfd_stab_section_find_nearest_line (bfd
 	         and directory.  */
 	      if (saw_fun == 0)
 		{
-		  info->indextable[i].val = bfd_get_32 (abfd, last_stab + VALOFF);
+		  if (sext_vma) 
+		    info->indextable[i].val = bfd_get_signed_32 (abfd, last_stab + VALOFF);
+		  else 
+		    info->indextable[i].val = bfd_get_32 (abfd, last_stab + VALOFF);
 		  info->indextable[i].stab = last_stab;
 		  info->indextable[i].str = str;
 		  info->indextable[i].directory_name = directory_name;
@@ -1166,7 +1174,10 @@ _bfd_stab_section_find_nearest_line (bfd
 	      if (name == NULL)
 		continue;
 
-	      info->indextable[i].val = bfd_get_32 (abfd, stab + VALOFF);
+	      if (sext_vma) 
+		info->indextable[i].val = bfd_get_signed_32 (abfd, stab + VALOFF);
+              else 
+		info->indextable[i].val = bfd_get_32 (abfd, stab + VALOFF);
 	      info->indextable[i].stab = stab;
 	      info->indextable[i].str = str;
 	      info->indextable[i].directory_name = directory_name;
@@ -1179,7 +1190,11 @@ _bfd_stab_section_find_nearest_line (bfd
 
       if (saw_fun == 0)
 	{
-	  info->indextable[i].val = bfd_get_32 (abfd, last_stab + VALOFF);
+	  if (sext_vma)
+	    info->indextable[i].val = bfd_get_signed_32 (abfd, last_stab + VALOFF);
+	  else
+	    info->indextable[i].val = bfd_get_32 (abfd, last_stab + VALOFF);
+
 	  info->indextable[i].stab = last_stab;
 	  info->indextable[i].str = str;
 	  info->indextable[i].directory_name = directory_name;
@@ -1267,7 +1282,10 @@ _bfd_stab_section_find_nearest_line (bfd
 	{
 	case N_SOL:
 	  /* The name of an include file.  */
-	  val = bfd_get_32 (abfd, stab + VALOFF);
+	  if (sext_vma)
+	    val = bfd_get_signed_32 (abfd, stab + VALOFF);
+	  else
+	    val = bfd_get_32 (abfd, stab + VALOFF);
 	  if (val <= offset)
 	    {
 	      file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
@@ -1281,8 +1299,11 @@ _bfd_stab_section_find_nearest_line (bfd
 	  /* A line number.  If the function was specified, then the value
 	     is relative to the start of the function.  Otherwise, the
 	     value is an absolute address.  */
-	  val = ((indexentry->function_name ? indexentry->val : 0)
-		 + bfd_get_32 (abfd, stab + VALOFF));
+	  if (sext_vma)
+	    val = bfd_get_signed_32 (abfd, stab + VALOFF);
+	  else
+	    val = bfd_get_32 (abfd, stab + VALOFF);
+	  val += indexentry->function_name ? indexentry->val : 0;
 	  /* If this line starts before our desired offset, or if it's
 	     the first line we've been able to find, use it.  The
 	     !saw_line check works around a bug in GCC 2.95.3, which emits
Index: binutils/rddbg.c
===================================================================
RCS file: /projects/bbp/cvsroot/systemsw/tools/src/binutils/binutils/rddbg.c,v
retrieving revision 1.1.1.5
retrieving revision 1.7
diff -u -p -r1.1.1.5 -r1.7
--- rddbg.c	2003/04/28 18:29:43	1.1.1.5
+++ rddbg.c	2003/08/07 22:46:09	1.7
@@ -114,10 +114,15 @@ read_section_stabs_debugging_info (abfd,
 		  { "LC_SYMTAB.stabs", "LC_SYMTAB.stabstr" } };
   unsigned int i;
   PTR shandle;
+  int sext_vma;
 
   *pfound = FALSE;
   shandle = NULL;
 
+  sext_vma = bfd_get_sign_extend_vma (abfd);
+  if (sext_vma == -1)
+    sext_vma = 0;
+
   for (i = 0; i < sizeof names / sizeof names[0]; i++)
     {
       asection *sec, *strsec;
@@ -176,7 +181,10 @@ read_section_stabs_debugging_info (abfd,
 	      type = bfd_get_8 (abfd, stab + 4);
 	      other = bfd_get_8 (abfd, stab + 5);
 	      desc = bfd_get_16 (abfd, stab + 6);
-	      value = bfd_get_32 (abfd, stab + 8);
+	      if (sext_vma)
+		value = bfd_get_signed_32 (abfd, stab + 8);
+	      else
+		value = bfd_get_32 (abfd, stab + 8);
 
 	      if (type == 0)
 		{


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