From: jrs@world.std.com (Rick Sladkey)
To: gas2@cygnus.com
Subject: ELF line numbers
Date: Wed, 21 Jun 1995 22:40:00 -0000 [thread overview]
Message-ID: <951322.023610.jrs@world.std.com> (raw)
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);
next reply other threads:[~1995-06-21 22:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-06-21 22:40 Rick Sladkey [this message]
1995-07-11 9:33 ` Ian Lance Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=951322.023610.jrs@world.std.com \
--to=jrs@world.std.com \
--cc=gas2@cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).