From vsilyaev@mindspring.com Sat Nov 20 22:14:17 1999
Return-Path: <vsilyaev@mindspring.com>
Received: from smtp10.atl.mindspring.net (smtp10.atl.mindspring.net [207.69.200.246])
	by hub.freebsd.org (Postfix) with ESMTP id EE52414F2F
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 20 Nov 1999 22:14:14 -0800 (PST)
	(envelope-from vsilyaev@mindspring.com)
Received: from mindspring.com (user-2ivebbs.dialup.mindspring.com [165.247.45.124])
	by smtp10.atl.mindspring.net (8.9.3/8.8.5) with ESMTP id BAA22308
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 21 Nov 1999 01:14:05 -0500 (EST)
Received: (from vsilyaev@localhost)
	by mindspring.com (8.9.3/8.9.3) id BAA00543;
	Sun, 21 Nov 1999 01:14:03 -0500 (EST)
	(envelope-from vsilyaev)
Message-Id: <199911210614.BAA00543@mindspring.com>
Date: Sun, 21 Nov 1999 01:14:03 -0500 (EST)
From: vns@delta.odessa.ua
Sender: vsilyaev@mindspring.com
Reply-To: vns@delta.odessa.ua
To: FreeBSD-gnats-submit@freebsd.org
Subject: DDB can't find symbol for address in kernel loadable modules.
X-Send-Pr-Version: 3.2

>Number:         15014
>Category:       kern
>Synopsis:       DDB can't find symbol for address in kernel loadable modules.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Nov 20 22:20:00 PST 1999
>Closed-Date:    Sun Nov 28 06:51:41 PST 1999
>Last-Modified:  Thu Sep 09 06:34:14 UTC 2010
>Originator:     Vladimir N. Silyaev
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:

	FreeBSD 4.0-CURRENT i386

	ELF kernel
	ELF KLD

>Description:

	DDB can't locate names to stack frame, when frames include pointer
        from kernel loadable module

>How-To-Repeat:

- Build kernel with DDB support.
- Load linux KLD (launch linux command).

Throw to DDB, then 
db> b linux_open
db> c

Run any linux command, for example:
> /compat/linux/bin/bash

Breakpoint at   linux_open:     pushl   %ebp
db> trace
_end(c4324280,c45f3f80,28051dc6,3,28054a10) at 0xc06ef344
syscall(2f,2f,2f,28054a10,3) at syscall+0x119
Xint0x80_syscall() at Xint0x80_syscall+0x26
db> c


>Fix:

Apply the following patch.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
--- /sys/kern/link_elf.c.orig	Fri Oct 29 18:12:02 1999
+++ /sys/kern/link_elf.c	Sat Nov 20 17:51:16 1999
@@ -958,17 +958,19 @@
 	const Elf_Sym* es;
 	const Elf_Sym* best = 0;
 	int i;
+	u_long st_value;
 
 	for (i = 0, es = ef->ddbsymtab; i < ef->ddbsymcnt; i++, es++) {
 		if (es->st_name == 0)
 			continue;
-		if (off >= es->st_value) {
-			if (off - es->st_value < diff) {
-				diff = off - es->st_value;
+		st_value = es->st_value + (u_long)ef->address;
+		if (off >= st_value) {
+			if (off - st_value < diff) {
+				diff = off - st_value;
 				best = es;
 				if (diff == 0)
 					break;
-			} else if (off - es->st_value == diff) {
+			} else if (off - st_value == diff) {
 				best = es;
 			}
 		}
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

After applying this patch, in the same circumstance, trace will be printing:
db> trace
linux_open(c4324280,c45f3f80,28051dc6,3,28054a10) at linux_open
syscall(2f,2f,2f,28054a10,3) at syscall+0x119
Xint0x80_syscall() at Xint0x80_syscall+0x26


P.S. It's looks like that the /sys/kern/link_aout.c have the same kind
of problem.


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: peter 
State-Changed-When: Sun Nov 28 06:51:41 PST 1999 
State-Changed-Why:  
Suggested changes applied and adapted for the link_aout.c code, revs: 
1.22      +7 -5      src/sys/kern/link_elf.c 
1.23      +7 -5      src/sys/kern/link_aout.c 
1.17.2.2  +7 -5      src/sys/kern/link_aout.c 
1.11.2.2  +7 -5      src/sys/kern/link_elf.c 
(The last two being -stable).  Thanks! 
Responsible-Changed-From-To: freebsd-bugs->pgollucci 
Responsible-Changed-By: pgollucci 
Responsible-Changed-When: Thu Sep 9 06:32:47 UTC 2010 
Responsible-Changed-Why:  
I will take it 

http://www.freebsd.org/cgi/query-pr.cgi?pr=15014 
Responsible-Changed-From-To: pgollucci->freebsd-bugs 
Responsible-Changed-By: pgollucci 
Responsible-Changed-When: Thu Sep 9 06:34:13 UTC 2010 
Responsible-Changed-Why:  
fat fingered the pr # 

http://www.freebsd.org/cgi/query-pr.cgi?pr=15014 
>Unformatted:
