Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Sep 2002 23:05:35 +0200
From:      Thomas Moestl <tmoestl@gmx.net>
To:        John Polstra <jdp@polstra.com>
Cc:        sparc@freebsd.org, jhb@freebsd.org
Subject:   Re: No gdb yet?
Message-ID:  <20020913210535.GC6560@crow.dom2ip.de>
In-Reply-To: <200209132045.g8DKjloj035471@vashon.polstra.com>
References:  <XFMail.20020913141454.jhb@FreeBSD.org> <200209132045.g8DKjloj035471@vashon.polstra.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 2002/09/13 at 13:45:47 -0700, John Polstra wrote:
> In article <XFMail.20020913141454.jhb@FreeBSD.org>, John Baldwin
> <jhb@FreeBSD.ORG> wrote:
> 
> > Jake has some sort of core dump analyzer.
> 
> Hey, Jake!  Yoohoo!  Could you point me to a copy of it? :-)

It's at
  http://people.freebsd.org/~jake/coredump.tar

I've attached a small patch that should make it work better with
stripped dynamic objects (particularly rtld) by looking for symbols in
the dynamic symtab too. 

	- Thomas

-- 
Thomas Moestl <tmoestl@gmx.net>	http://www.tu-bs.de/~y0015675/
              <tmm@FreeBSD.org>	http://people.FreeBSD.org/~tmm/
PGP fingerprint: 1C97 A604 2BD0 E492 51D0  9C0F 1FE6 4F1D 419C 776C

diff -ur coredump/coredump.c coredump.tmm/coredump.c
--- coredump/coredump.c	Thu Jul 18 00:27:29 2002
+++ coredump.tmm/coredump.c	Fri Sep 13 23:04:02 2002
@@ -252,18 +252,26 @@
 static Elf_Sym *
 elf_find_sym_by_name(Elf_Ehdr *e, char *name)
 {
-	Elf_Shdr *sh;
+	Elf_Shdr *shstr, *shtab;
 	Elf_Sym *st;
 	char *strtab;
 	int i;
 
-	if ((sh = elf_find_shdr(e, ".strtab", 0)) == NULL)
+	if ((shstr = elf_find_shdr(e, ".strtab", 0)) != NULL &&
+	    (shtab = elf_find_shdr(e, ".symtab", 0)) != NULL) {
+		strtab = (char *)e + shstr->sh_offset;
+		st = (Elf_Sym *)((char *)e + shtab->sh_offset);
+		for (i = 0; i < shtab->sh_size / sizeof(*st); i++) {
+			if (strcmp(name, strtab + st[i].st_name) == 0)
+				return (&st[i]);
+		}
+	}
+	if ((shstr = elf_find_shdr(e, ".dynstr", 0)) == NULL ||
+	    (shtab = elf_find_shdr(e, ".dynsym", 0)) == NULL)
 		return (NULL);
-	strtab = (char *)e + sh->sh_offset;
-	if ((sh = elf_find_shdr(e, ".symtab", 0)) == NULL)
-		return (NULL);
-	st = (Elf_Sym *)((char *)e + sh->sh_offset);
-	for (i = 0; i < sh->sh_size / sizeof(*st); i++) {
+	strtab = (char *)e + shstr->sh_offset;
+	st = (Elf_Sym *)((char *)e + shtab->sh_offset);
+	for (i = 0; i < shtab->sh_size / sizeof(*st); i++) {
 		if (strcmp(name, strtab + st[i].st_name) == 0)
 			return (&st[i]);
 	}

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-sparc" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020913210535.GC6560>