From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 From: Jan Vrany Reply-To: Jan Vrany 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-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Fri, 28 Jan 2022 16:26:04 -0000 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