public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
* ELF line numbers
@ 1995-06-21 22:40 Rick Sladkey
  1995-07-11  9:33 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Rick Sladkey @ 1995-06-21 22:40 UTC (permalink / raw)
  To: gas2

When I first tried GNU ld on SunOS 4.1.x, I liked the inclusion of
file, function and line number in undefined error messages.  I finally
got tired of seeing `.text+0xXXXX' messages and so I tried to add this
feature for ELF on Solaris 2.x and Linux.  I implemented a simple
version which will work even without debugging but omits the line
number (based on the one in aoutx.h).

Then as I was about to embark on the full debug version, I realized
that using the .stabs section will work for Solaris and Linux but not
DWARF.  In which file should one implement the stabs version?  It
seems that elfcode.h is too general and elf32-{i386,sparc}.c are too
specific.

bfd ChangeLog:

Thu Jun 22 02:21:39 1995  Rick Sladkey  <jrs@world.std.com>

	* elfcode.h (elf_find_nearest_line): Handle the simple
	case where there is no debugging information.

ld ChangeLog:

Thu Jun 22 02:21:39 1995  Rick Sladkey  <jrs@world.std.com>

	* ldmisc.c (undefined_symbol): Don't print the line number if
	it isn't meaningful.
	
*** gas-950619/bfd/elfcode.h-dist	Mon Jun 19 04:18:54 1995
--- gas-950619/bfd/elfcode.h	Wed Jun 21 15:24:09 1995
***************
*** 3397,3403 ****
       CONST char **functionname_ptr;
       unsigned int *line_ptr;
  {
!   return false;
  }
  
  int
--- 3397,3450 ----
       CONST char **functionname_ptr;
       unsigned int *line_ptr;
  {
!   /* Run down the file looking for the filename and function.  */
!   asymbol **p;
!   static  char buffer[100];
!   static  char filename_buffer[200];
!   CONST char *main_file_name = NULL;
! 
!   bfd_vma high_line_vma = ~0;
!   bfd_vma low_func_vma = 0;
!   asymbol *func = 0;
!   *filename_ptr = abfd->filename;
!   *functionname_ptr = 0;
!   *line_ptr = 0;
!   if (symbols != (asymbol **)NULL) {
!     for (p = symbols; *p; p++) {
!       elf_symbol_type  *q = (elf_symbol_type *)(*p);
!     next:
!       switch (ELF_ST_TYPE(q->internal_elf_sym.st_info)){
!       case STT_FILE:
! 	main_file_name = q->symbol.name;
! 	break;
! 
!       case STT_FUNC:
! 	{
! 	  /* We'll keep this if it is nearer than the one we have already */
! 	  if (q->symbol.value >= low_func_vma &&
! 	      q->symbol.value <= offset) {
! 	    low_func_vma = q->symbol.value;
! 	    func = (asymbol *)q;
! 	  }
! 	  if (func) {
! 	    CONST char *function = func->name;
! 	    char *p;
! 	    strncpy (buffer, function, sizeof (buffer) - 1);
! 	    buffer[sizeof(buffer)-1] = 0;
! 	    *functionname_ptr = buffer;
! 	    goto done;
! 
! 	  }
! 	}
! 	break;
!       }
!     }
!   }
! 
!  done:
!   if (main_file_name)
!     *filename_ptr = main_file_name;
!   return true;
  }
  
  int
*** gas-950619/ld/ldmisc.c-dist	Fri May 12 14:54:47 1995
--- gas-950619/ld/ldmisc.c	Wed Jun 21 15:13:48 1995
***************
*** 297,303 ****
  		      last_function = buystring (functionname);
  		    }
  		  discard_last = false;
! 		  fprintf (fp, "%s:%u", filename, linenumber);
  		}
  	      else if (linenumber != 0) 
  		finfo (fp, "%B:%s:%u", abfd, filename, linenumber);
--- 297,306 ----
  		      last_function = buystring (functionname);
  		    }
  		  discard_last = false;
! 		  if (linenumber != 0) 
! 		    finfo (fp, "%s:%u", filename, linenumber);
! 		  else
! 		    finfo (fp, "%s(%s+0x%v)", filename, section->name, offset);
  		}
  	      else if (linenumber != 0) 
  		finfo (fp, "%B:%s:%u", abfd, filename, linenumber);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ELF line numbers
  1995-06-21 22:40 ELF line numbers Rick Sladkey
@ 1995-07-11  9:33 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 1995-07-11  9:33 UTC (permalink / raw)
  To: jrs; +Cc: gas2

   From: jrs@world.std.com (Rick Sladkey)
   Date: Thu, 22 Jun 1995 02:36:10 EDT

   When I first tried GNU ld on SunOS 4.1.x, I liked the inclusion of
   file, function and line number in undefined error messages.  I finally
   got tired of seeing `.text+0xXXXX' messages and so I tried to add this
   feature for ELF on Solaris 2.x and Linux.  I implemented a simple
   version which will work even without debugging but omits the line
   number (based on the one in aoutx.h).

Thanks.  I checked this in.

   Then as I was about to embark on the full debug version, I realized
   that using the .stabs section will work for Solaris and Linux but not
   DWARF.  In which file should one implement the stabs version?  It
   seems that elfcode.h is too general and elf32-{i386,sparc}.c are too
   specific.

Actually, the GNU tools support .stabs debugging for any ELF target.
That is actually the only to implement C++ debugging in ELF right now,
because g++ does not support DWARF.  So, elfcode.h (actually, the
function is now in elf.c) is the right place to handle both stabs and
DWARF debugging information.

Ian


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1995-07-11  9:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-06-21 22:40 ELF line numbers Rick Sladkey
1995-07-11  9:33 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).