From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (wildebeest.demon.nl [212.238.236.112]) by sourceware.org (Postfix) with ESMTPS id EA8AC385781B for ; Mon, 23 Aug 2021 21:01:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EA8AC385781B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from reform (deer0x0b.wildebeest.org [172.31.17.141]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id EF1103000ADC; Mon, 23 Aug 2021 23:00:59 +0200 (CEST) Received: by reform (Postfix, from userid 1000) id B567B2E806B9; Mon, 23 Aug 2021 23:00:59 +0200 (CEST) Date: Mon, 23 Aug 2021 23:00:59 +0200 From: Mark Wielaard To: Jeff Lin Cc: "elfutils-devel@sourceware.org" Subject: Re: Using dwarf_getfuncs to get function from object stored in memory Message-ID: References: <9584640F-85CC-4CEF-B059-0044C7FE2151@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9584640F-85CC-4CEF-B059-0044C7FE2151@xilinx.com> X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Aug 2021 21:01:02 -0000 Hi Jeff, On Tue, Aug 17, 2021 at 03:40:08AM +0000, Jeff Lin via Elfutils-devel wrote: > I’ve written code to extract function from a shared object with > dwarf_begin api that finds the dwarf objects with the file > descriptor using dwarf_getfuncs. However, when I tried to parse the > same object that is loaded into memory first, dwarf_getfuncs is not > able to get the function. In the case of accessing the object that > is in memory, I used the following line to get the dwarf object: > > Elf *ehandle = elf_memory(const_cast(so_file), size); > Dwarf *dw = dwarf_begin_elf(ehandle, DWARF_C_READ, NULL); > > I am able to get the offset and tag with dwarf_nextcu, but errors > out with dwarf_getfuncs. Does anyone know why dwarf_getfuncs does > return properly when trying to process dwarf object that was store > in memory? If the ELF in memory is the same as the ELF on disk I don't know why dwarf_getfuncs would work differently. Does the callback get called? Does dwarf_getfuncs return -1? What does dwarf_errmsg say? Cheers, Mark