From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 29 05:51:53 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5D49916A4CE for ; Thu, 29 Apr 2004 05:51:53 -0700 (PDT) Received: from 15pc221.sshunet.nl (15pc221.sshunet.nl [131.211.221.15]) by mx1.FreeBSD.org (Postfix) with ESMTP id BF1A643D5A for ; Thu, 29 Apr 2004 05:51:52 -0700 (PDT) (envelope-from pieter@thelostparadise.com) Received: from thedarkside.nl ([172.16.0.4]) by 15pc221.sshunet.nl (8.12.8p2/8.12.8) with ESMTP id i3TCpmKM030654; Thu, 29 Apr 2004 14:51:48 +0200 (CEST) (envelope-from pieter@thelostparadise.com) Received: from [10.0.0.3] (edinburgh [10.0.0.3]) by thedarkside.nl (8.12.8p2/8.12.8) with ESMTP id i3TCpmPQ034954; Thu, 29 Apr 2004 14:51:48 +0200 (CEST) (envelope-from pieter@thelostparadise.com) From: "P. de Boer" To: Dag-Erling =?ISO-8859-1?Q?Sm=F8rgrav?= In-Reply-To: References: <1083167960.653.23.camel@edinburgh.thedarkside.tix> Content-Type: text/plain; charset=iso-8859-1 Organization: The Lost Paradise Message-Id: <1083243107.640.13.camel@edinburgh.thedarkside.tix> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Thu, 29 Apr 2004 14:51:47 +0200 Content-Transfer-Encoding: 8bit X-TheLostParadise-MailScanner-Information: Please contact the ISP for more information X-TheLostParadise-MailScanner: Found to be clean cc: freebsd-hackers@freebsd.org Subject: Re: Extracting symbol info out of processes at runtime X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: pieter@thelostparadise.com List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Apr 2004 12:51:53 -0000 On Thu, 2004-04-29 at 14:30, Dag-Erling Smørgrav wrote: > "P. de Boer" writes: > > For a little private project I'm working at, I need to find the address > > of a function which is inside a shared library of a running process, OR > > the base address the library is running at > > man dlinfo Well, yes, dlinfo() would be very useful, if it was not for my wish to read the link_map from another proces, using ptrace(). I've looked at rtld-elf.c, to see what dlinfo() does: it finds the object by the given address and then 'returns' the link_map for that object. However, I can't find out where this info would be in the memory image of a running process. Apparantly the objects the loader keeps info on, are in a linked list, 'obj_list', which is a global var of rtld-elf.c. Would this mean the info I'm trying to find is on the stack of the dynamic linker and therefor can't be found as long as I don't know where the linker is loaded into memory? Sounds like a chicken-and-egg problem in that case. If so, that would make things suckier than they already are, since I'm actually working on a Linux binary/libs, running on FreeBSD at the moment.. I hope(d) there was/is a generic method for all ELF binaries available, but if not, I'd better bug the Linux people a bit. -- Pieter de Boer