From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id WRcQNzUZ9GEABgAAWB0awg (envelope-from ) for ; Fri, 28 Jan 2022 11:26:29 -0500 Received: by simark.ca (Postfix, from userid 112) id D00151F3B7; Fri, 28 Jan 2022 11:26:29 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 61C581EE18 for ; Fri, 28 Jan 2022 11:26:29 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5E8D9382C401 for ; Fri, 28 Jan 2022 16:26:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E8D9382C401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1643387188; bh=gXJlQ6iC6ra2BaBcCwJhyQOF6xBV6fu9BwToaxgTMeU=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ZxRSTytPuCZldJno+mhd5WrO5ghGkkLD5dGazVdEOmpgQlBUUhvTG55Jw61g0dRxQ o9C3fJH9Jka1hgG8COy/DOz3c3cAN6oKohPFKP/fOnJpuhFH+VcgNMw1h7hJyQCa5U 2pxlJakRuMqqkzGx0pqZ/jj7zPJ+x6Rsd5fDrjNs= Received: from mail-4022.proton.ch (mail-4022.proton.ch [185.70.40.22]) by sourceware.org (Postfix) with ESMTPS id 09C9A3858418 for ; Fri, 28 Jan 2022 16:26:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 09C9A3858418 Date: Fri, 28 Jan 2022 16:25:52 +0000 To: Matthew Rinaldi , gdb@sourceware.org Subject: Re: Adding user-defined symbols to GDB Message-ID: <7dbfd87283aea7af635a197b21d7a93db0694cd8.camel@vrany.io> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Jan Vrany via Gdb Reply-To: Jan Vrany Errors-To: gdb-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb" Hi, On Wed, 2022-01-26 at 18:55 -0500, Matthew Rinaldi via Gdb wrote: > Hello, > > I have a list of symbols that I have parsed out from a section within > the binary. The data is not in any standard symbol table format. I have > extracted the symbol's name and address. I want to add these symbols to > GDB, but it is non-trivial. The solutions that I have seen for adding > new user-defined symbols do not look ideal for a seemingly simple task. > > Example: https://github.com/mahaloz/decomp2gef/blob/main/decomp2gef.py#L2= 47 > > Is it possible to have a feature/command where the user could add > symbols directly to GDB without the use of an objfile? > > I brought it up with Simon Marchi, and he said the following: > > But off-hand, I don't see why this wouldn't be possible. Each objfile > > could have a list of user-defined symbols, that lookup_symbol_in_objfil= e > > would search in addition to the other regular methods. > I'm working in context of (language) VMs and have similar problem. I have all my support code written in Python so it'd be nice if I could do this kind of thing also from Python (as opposed to using "jit-reader" interface to do this part or generating elf/PE/coff). Maybe we can provide Python API similar to one of jit-reader to allow one to build a symtab(s) and add them to (either existing of freshly created) objfiles?=C2=A0We can provide "gdb.SymtabBuilder" python object to= build a symtab and then "install" it into objfile just like finalize_symtab() does in jit.c (perhaps we can factor out some common code). Jan > Thank you, > Matthew Rinaldi