From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by sourceware.org (Postfix) with ESMTPS id D99E43858D20 for ; Thu, 27 Jan 2022 01:53:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D99E43858D20 Received: by mail-io1-xd35.google.com with SMTP id e79so1780564iof.13 for ; Wed, 26 Jan 2022 17:53:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VEL0a/hSVGnkUeq+/JAUqUdYjXlb0Phkv2j24+PLW1c=; b=kZlGNLWSqT4+nk0oieTZUy4KvVyMVM13heY9rEM+sNwFOVGmkNCMHR9w+ryrdIwWxU AYRQqBDjqVM0G08NwGtaTbQjViIOhG7uyVsoWzU11IdZANeB7us9gyPI6Ez/oa8kCxfp PtdJtf0zZv60nOK5ThSPheg2Jh/jNWrzsH1agNgSvRGeia0uL1/C/xTwUUK1WomNkzMN Wn6qy9QBj4ZcVr3F5u4wAAaIqJeAu58Nlq7NfE4HpApq6F+w6YZCicgKA5chV1fPiYwC hmhd+xx/Q2lKxXna3ZpV/PaVlOTc/MEqwzTKIlZnk0XkFD3KC37EAzKEIx+SvA/WU4Tj 7JDQ== X-Gm-Message-State: AOAM531KgeXnYeg63t069rloPkqvzMnnNyw6NOOpLxIKVCTj5EB4EvQO ZyH5ZJZixI8Us0ylF1ikbYcd7JpBbOCXOKOGAJSc5g== X-Google-Smtp-Source: ABdhPJzhzjMYS4DKcHQxbBRCynMH6L1nHg5lhxiV/LKRYEB68ACyUZaSuttjVaMzlYD4vFKvv9hoA1Zc4yonJ8ri6ZM= X-Received: by 2002:a02:cc54:: with SMTP id i20mr746938jaq.219.1643248407071; Wed, 26 Jan 2022 17:53:27 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sterling Augustine Date: Wed, 26 Jan 2022 17:53:16 -0800 Message-ID: Subject: Re: Adding user-defined symbols to GDB To: Matthew Rinaldi Cc: gdb@sourceware.org X-Spam-Status: No, score=-18.3 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Thu, 27 Jan 2022 01:53:33 -0000 I don't know of a way to do it without an objfile, but the method in that script is far more complicated than it needs to be. I would have to work out the details, but a linker script with simple symbol-value assignments could easily produce this. symbol0 = value0 symbol1 = value1 then run ld with the right options so it doesn't pull in startfiles and what not. Then add-symbol-file from inside gdb. On Wed, Jan 26, 2022 at 3:55 PM 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#L247 > > 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_objfile > > would search in addition to the other regular methods. > > Thank you, > Matthew Rinaldi >